package com.yc.navy.springmvc.core;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * 处理请求的映射对象
 * @author 主机
 *
 */
public class HandlerMapperInfo{
	private Method method; // 处理这个请求的方法
	private Object obj; // 这个方法是哪个对象
	private Object[] ages; // 这个方法需要的参数列表
	private String requestMethod; // 请求方式是GET、POST还是都行
	
	@Override
	public String toString() {
		return "HandlerMapperInfo [method=" + method + ", obj=" + obj + ", ages=" + Arrays.toString(ages)
				+ ", requestMethod=" + requestMethod + "]";
	}

	public HandlerMapperInfo(Method method, Object obj, String requestMethod) {
		super();
		this.method = method;
		this.obj = obj;
		this.requestMethod = requestMethod;
	}

	public HandlerMapperInfo() {
		super();
	}

	public Method getMethod() {
		return method;
	}

	public void setMethod(Method method) {
		this.method = method;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public Object[] getAges() {
		return ages;
	}

	public void setAges(Object[] ages) {
		this.ages = ages;
	}

	public String getRequestMethod() {
		return requestMethod;
	}

	public void setRequestMethod(String requestMethod) {
		this.requestMethod = requestMethod;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Arrays.deepHashCode(ages);
		result = prime * result + ((method == null) ? 0 : method.hashCode());
		result = prime * result + ((obj == null) ? 0 : obj.hashCode());
		result = prime * result + ((requestMethod == null) ? 0 : requestMethod.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		HandlerMapperInfo other = (HandlerMapperInfo) obj;
		if (!Arrays.deepEquals(ages, other.ages))
			return false;
		if (method == null) {
			if (other.method != null)
				return false;
		} else if (!method.equals(other.method))
			return false;
		if (this.obj == null) {
			if (other.obj != null)
				return false;
		} else if (!this.obj.equals(other.obj))
			return false;
		if (requestMethod == null) {
			if (other.requestMethod != null)
				return false;
		} else if (!requestMethod.equals(other.requestMethod))
			return false;
		return true;
	}
	
}
